<script type="text/javascript">

    function proses() {
        var p = $('#id_periode_fk').val();
        var ga = $('#id_grub_absen_fk').val();
        if(p != "" && ga != "") {
            // console.log("proses => "+p+" : "+ga);
            // fungsi di detail_absen.php
            reloadTabel(p,ga);
            ambilPeriode(p);

            // fungsi di piket.php
            reloadTabelPiket();

            // fungsi di rapat.php
            reloadTabelRapat();

            // fungsi di lembur.php
            reloadTabelLembur();
        } else {
            // console.log("Kosong");
            $.messager.alert('Info','Periode dan Grub Absen tidak boleh kosong!','info');
        }
    }

    function profileKaryawan(){
        loadPage(gs_path + '/hrd_karyawan/edit/?id_karyawan_pk='+$('#id_karyawan_pk').getval());
    }

    $(document).ready(function() {
        // Setup Form
        $('#form_master').setupForm([
            { name: 'id_karyawan_pk', type: 'text', size: 'medium', maxlength: 10, noempty:true },
            { name: 'nama_karyawan', type: 'text', size:'medium' },
            { name: 'no_finger_scan', type: 'text', size:'short' },
            // { name: 'id_periode_fk', size: 'medium', data:<?php echo json_encode(array_merge(array(array('value'=>'','display'=>'')),$listPeriode)); ?> },
            { name: 'id_periode_fk', size: 'medium', data:<?php echo json_encode($listPeriode); ?> },
            { name: 'id_grub_absen_fk', size: 'medium', data:<?php echo json_encode(array_merge(array(array('value'=>'','display'=>'')),$listGrubAbsen)); ?> },
        ], 
            <?php echo json_encode($data); ?>
        );

        
        <?php if($mode=="edit"){ ?>
        $('#id_karyawan_pk').readonly();
        $('#nama_karyawan').readonly();
        $('#no_finger_scan').readonly();
        $('#id_grub_absen_fk').readonly();
        <?php } ?>

        // Set Action Button
        var buttons = [
                       { label: 'Close', icon: 'cancel', onclick: function() { loadPage('/'+controller+'/Index'); } }];
        setAction(buttons);
        
        // Create Tab
        $('#tt').tabs({ border:false });  
        
        // Focus at First Object
        // $('#form_master').focusFirst();

        // JANGAN LUPA DI HAPUS
        // proses();

    });
</script>

<div id="form_master_message" style="display:none;"></div>
<fieldset style="width:500px;">
<table class="tb_form" style="display:none; width:100%; " cellpadding="0" cellspacing="0" border="0">   
    <tr>
        <td class="label">NIK</td>
        <td><input id="id_karyawan_pk" /> <button class="easyui-linkbutton" iconCls="icon-edit" onclick="profileKaryawan()">Profile</button></td>
        <!-- <td colspan="2" rowspan="8"><img src="/primkokas/files/people.png" width="150" height="200" border="3" style="float:right;"> </td> -->
    </tr>
    <tr>
        <td class="label">Nama Karywan</td>
        <td><input id="nama_karyawan" /></td>
    </tr>
    <tr>
        <td class="label">No Finger Scan</td>
        <td><input id="no_finger_scan" /></td>
    </tr>
    <tr>
        <td class="label">Grub Absen</td>
        <td><input id="id_grub_absen_fk" /></td>
    </tr>
    <tr><td><br><br></td></tr>
    <tr>
        <td class="label">Periode</td>
        <td><input id="id_periode_fk" /></td>
    </tr>
    <tr>
    	<td></td>
    	<td><button class="easyui-linkbutton" iconCls="icon-reload" onclick="proses()">Proses</button></td>
    </tr>
</table>
</fieldset>
<br><br>

<div id="tt" class="easyui-tabs" style="min-height:400px;"> 

    <div title="Absen" style="overflow:auto;padding:10px;">
        <?php require_once('detail_absen.php'); ?>
    </div>

    <div title="Lembur" style="overflow:auto;padding:10px;">  
        <?php require_once('lembur.php'); ?>
    </div>
    
    <div title="Rapat" style="overflow:auto;padding:10px;">  
        <?php require_once('rapat.php'); ?>
    </div>

    <div title="Piket" style="overflow:auto;padding:10px;">  
        <?php require_once('piket.php'); ?>
    </div>

</div>